#include<bits/stdc++.h>
using namespace std;
int main()
{
	cout<<"12"<<endl;
	cout<<"9709"<<endl;
	cout<<"96"<<endl;
	cout<<"109"<<endl;
	cout<<"108"<<endl; 
    return 0;
}
